<script>
export default {
    name: "Login",
    data(){
        return {
            userList:["zhangsan","lisi","wangwu","zhaoliu"]
        }
    },
    methods:{
        login(e){
            if(this.userList.includes(e.target.value)){
                localStorage.setItem("username",e.target.value);
                // 1
                // if(this.$route.query.returnUrl)
                //     this.$pages.push(this.$route.query.returnUrl);
                // else this.$pages.push("/")

                // 2
                this.$router.push(this.$route.query.returnUrl || "/")
            }else{
                alert("账号输入错误！")
            }
        }
    }
}
</script>

<template>
<div>
    <input  @keydown.enter="login" style="width:300px;" type="text" placeholder="请输入您的账号，回车登陆">
</div>
</template>

<style scoped>

</style>